package cn.jsu.oj.dispatchServer.satellite.mode.strategy;

import cn.jsu.oj.dispatchServer.satellite.pojo.net.LossNet;
import org.springframework.stereotype.Service;

/**
 * 服务端策略
 *
 * @author shan
 * @date 2022/07/13
 */
@Service("serverStrategy")
public class ServerStrategy extends AbsStrategy {
    
    @Override
    public void execute() {
        LossNet lossNet = (LossNet) super.premise;
        String missTarget = lossNet.getClient();
        if (super.activeClientCheck(missTarget)) {
            return;
        }
        try {
            super.satelliteServer.getChannel().writeAndFlush(lossNet.serialize());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
